package cn.cdyx.common;

import cn.cdyx.common.utils.DateTimeUtil;
import cn.cdyx.common.utils.SecuritUtil;
import org.junit.Test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;

/**
 * @Author Watermelon
 * @Date 2023-01-13 8:42
 */
public class test {

    /**
     * LocalDatetime测试
     */
    @Test
    public void test01(){
        String format = String.format("%02d", 12);
        System.out.println(format);
        Date a = new Date();
        Date b ;
        try {
             b = new SimpleDateFormat("yyyyMM").parse(Integer.toString(2023)+String.format("%02d", 1));
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }

        if (a.compareTo(b)>=0){
            System.out.println("aaa");
        }

    }

    /**
     *
     * @throws Exception
     * 加解密测试
     */
    @Test
    public void jjm() throws Exception {
        String cKey = "CDYXINTERFACEKEY";
        String mima = "ygsS0CMCd67CE+WmIjIgyBIpkJX5BO5STpPsqgJEHTc=";
        String mm = "电子病历测试医院";
        // 解密
        String DeString = SecuritUtil.decrypt(mima, cKey);
        System.out.println("解密后的字串是：" + DeString);

        String enString = SecuritUtil.encrypt(mm, cKey);
        System.out.println("加密后的字串是：" + enString);
    }

    /**
     * 补0
     * @throws Exception
     */
    @Test
    public void bl() throws Exception {
        String a = "123456";
        String b = String.format("%018d",Integer.valueOf(a));
        System.out.println(b);

    }

    /**
     * 去时分秒
     */
    @Test
    public void date(){
        Date date = new Date();
        Date date1 = DateTimeUtil.YDHLDate(date);
        System.out.println(date);
        System.out.println(date1);
    }
}
